/*
 * addon_intf.h
 *
 *  Created on: 2010-1-7
 *      Author: gavinkwoe
 */

#ifndef ADDON_TIMER_H_
#define ADDON_TIMER_H_

#include "addon_features.h"
#include "addon_std.h"
#include "addon_objbase.h"

/*************************************************************************
* TYPE
*************************************************************************/

typedef void	( ADDON_PROC addon_timeout_fptr_t )( ADDON_REF(IObject) sender );

/*************************************************************************
* INTERFACE
*************************************************************************/

ADDON_INTERFACE_( IAddonTimer, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( GetUserData )	( ADDON_REF(IObject) thiz, OUT void ** pusr_data );
	ADDON_METHOD( SetUserData )	( ADDON_REF(IObject) thiz, IN void * usr_data );
	ADDON_METHOD( SetCallback )	( ADDON_REF(IObject) thiz, IN addon_timeout_fptr_t hdlr );
	ADDON_METHOD( Start )		( ADDON_REF(IObject) thiz, IN unsigned long delay_ms );
	ADDON_METHOD( Stop )		( ADDON_REF(IObject) thiz );
};

/*************************************************************************
* DECLARATION
*************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif	// #if defined(__cplusplus)

ADDON_IMPORT ADDON_REF(IObject)	addon_create_timer( void * reserved );

#if defined(__cplusplus)
};
#endif	// #if defined(__cplusplus)

/*************************************************************************
* MACRO
*************************************************************************/

#define IAddonTimer_VTBL( p )				ADDON_GET_VTBL_(p, IAddonTimer)
#define IAddonTimer_CALL( p, a )			IAddonTimer_VTBL(p)->a
#define IAddonTimer_GetUserData( p, a )		IAddonTimer_CALL( p, GetUserData )( p, a )
#define IAddonTimer_SetUserData( p, a )		IAddonTimer_CALL( p, SetUserData )( p, a )
#define IAddonTimer_SetCallback( p, a )		IAddonTimer_CALL( p, SetCallback )( p, a )
#define IAddonTimer_Start( p, a )			IAddonTimer_CALL( p, Start )( p, a )
#define IAddonTimer_Stop( p )				IAddonTimer_CALL( p, Stop )( p )

#endif /* ADDON_TIMER_H_ */
